package com.example.mapp.buildSql;

import com.example.entity.authority.SystemRole;
import org.apache.ibatis.jdbc.SQL;

/**
 * Created by youkun on 2017/9/4.
 */
public class SystemRoleMappSql {

    public String queryList(SystemRole systemRole){
        String select = " id,role_describe,role_name,use_state ";

        String table = " system_role ";

        String whereParam="";
        if(null!=systemRole.getRoleName() && systemRole.getRoleName().length()>0){
            systemRole.setRoleName('%'+systemRole.getRoleName()+'%');
            whereParam+=" and role_name like #{roleName}";
        }
        String  where = " use_state='1' " +whereParam;
        return new SQL(){{
            SELECT(select);
            FROM(table);
            WHERE(where);
        }
        }.toString();
    }

}
